/**
 * Created by HEKI on 8/24/2016.
 */

exports.getMerchantSessionFoodCart = function (req, res) {
    var foodCart = req.session.foodCart;
    if (foodCart) {
        var mId = req.query.mId;
        res.json(foodCart[mId]);
    }
    else
        res.json([]);
}
exports.addFoodCartChangeToSessionFilter = function (req, res, next) {
    if (req.session.hasOwnProperty("client")) {
        if (req.session.client != null) {
            console.log("client......." + req.session.hasOwnProperty("client"));
            next();
            console.log("......")
        }
        else {
            res.send("error");
        }
    }
    else {
        res.send("error");
    }
}

exports.addFoodCartChangeToSession = function (req, res) {
    var foodCart = req.session.foodCart;
    var mId = req.body.mId;
    if (foodCart) {
        foodCart[mId] = req.body.foodCart;
        res.send("success");
        req.session.foodCart = foodCart;
    }
    else {
        req.session.foodCart = {};
        foodCart = req.session.foodCart;
        foodCart[mId] = req.body.foodCart;
        req.session.foodCart = foodCart;
        res.send("success");
    }
}